#!/bin/bash

# 需要安装交叉编译工具链
sudo apt install -y gcc-arm-linux-gnueabihf

# 解压缩busybox
tar -axf busybox-1.36.1.tar.bz2

# 应用补丁
#patch -p1 < busybox-1.36.1.patch

# 导入默认配置
cp fsmp1a_config busybox-1.36.1/.config
cd busybox-1.36.1
make oldconfig

# 编译
make -j$(nproc)

# 安装
make install CONFIG_PREFIX=rootfs

# 创建其他目录
cd rootfs
mkdir -p boot dev etc/init.d lib media mnt opt run srv tmp var sys proc
cp ../examples/bootfloppy/etc/inittab etc/
cp ../examples/bootfloppy/etc/fstab etc/
cp ../examples/bootfloppy/etc/init.d/rcS etc/init.d/

# 挂载sysfs
echo -e "sysfs\t\t/sys\tsysfs\tdefaults    0\t0" >> etc/fstab

# 将rootfs目录放到NFS共享目录中
cd ..
mv rootfs ..
cd ..
mkdir -p ~/share
cp -a rootfs ~/share

